﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SocialShare.BusinessEntities;
using System.Data;

namespace SocialShare.BusinessLogicLayer
{
    internal partial class SocialShare_MemberProfilesBLL
    {
        internal SocialShare_MemberProfiles GetUserProfileByID(String UserId)
        {
            return (_socialShareDatabaseContext.SocialShare_MemberProfiles.FirstOrDefault(memObject => memObject.UserId == UserId));
        }

        internal void UpdateSocialShareMemberProfiles(SocialShare_MemberProfiles updatedSocialShare_MemberProfiles)
        {
          
            //attaching and making ready for parsistance
            if (updatedSocialShare_MemberProfiles.EntityState == EntityState.Detached)
                _socialShareDatabaseContext.SocialShare_MemberProfiles.Attach(updatedSocialShare_MemberProfiles);
            _socialShareDatabaseContext.ObjectStateManager.ChangeObjectState(updatedSocialShare_MemberProfiles, System.Data.EntityState.Modified);
            int numberOfAffectedRows = _socialShareDatabaseContext.SaveChanges();
            if (numberOfAffectedRows == 0)
                throw new InvalidOperationException("No socialShare_MemberProfiles updated!");
        }
        
    }
}
